15 minute volume takes the VMT for each time bin and divides by the length of the segment. Unit: Vehicles per mile. Speed is the segment length divided by the travel time ( * 60). Unit: Miles per hour. Hourly_Flow is the 15 minute volume multipled by 4 and divided by the number of lanes. Unit: Vehicles per hour. Density is the Hourly Flow divided by speed. Unit: Vehicles per hour.
We also create a variable that measures the delay type experienced by the segment. Weather (snow) events and crashes were tracked for the time period. If the segment experiences a weather event and a crash, weather will be the controlling delay type.
Segments <- DBI::dbReadTable(drv, 'Segments_494') %>%
filter(!is.na(Length)) %>%
select(Segment = Segment_No, Lanes, Length) %>%
arrange(Segment)
Data_494 <- merge(Data_494, Segments, by = 'Segment')
Rel <- Data_494 %>% mutate(Vol_15_min = VMT_total/Length,
Speed = Length/TT_mean*60,
Hourly_Flow = Vol_15_min*4/Lanes,
Dens = Hourly_Flow/Speed,
Hour = as.factor(format(DateTime,format = '%H')),
Month = as.factor(format(DateTime,format = '%m')),
WeekDay = as.factor(weekdays(DateTime)),
DateTimeSec = as.numeric(DateTime),
Delay_type = (ifelse(weather == 1,
'Weather',
ifelse(Crash == 1,
'Crash',
'None'))),
is_Delay = ifelse(Delay_type == 'None', 'No_Delay', 'Delay'),
Index = seq(1,length(Speed),1)) %>%
filter(!is.na(DateTime))
ggplot(Rel,aes(x = as.factor(Segment),y = TT_mean)) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(alpha = 0.5)
# Rel %>%
# filter(Segment == 9) %>%
# arrange(desc(TT_mean)) %>%
# print(n=20)
bins <- c(seq(floor(min(Rel$Dens)),50,2),60,70,80,90,100,125,150,200,300,400,480)
#1S
# bins <- c(seq(floor(min(Rel_2014$Dens)),50,2),
# 60,70,80,100,125,150,round(max(Rel_2014$Dens)+1,0))
Rel$cut <- cut(Rel$Dens,bins,echo.lowest = TRUE)
Rel$Density_bin <- as.numeric(stringi::stri_match_last_regex(Rel$cut,'[0-9]+'))
d <- Rel %>%
group_by(Density_bin, Segment) %>%
summarise(Count = n()) %>%
arrange(Density_bin) %>%
dcast(Density_bin ~ Segment)
## Using 'Count' as value column. Use 'value.var' to override
We will break down the dataset into each delay type and then further into percentiles.
The percentiles choosen are 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95.
For each quantile a travel time quantile is calculated. We also want to calculate a Free Floew Speed for each quantile.
The Free Flow speeds were calcuated using the 95th percentile speeds.
A look at the Density vs travel time plots. A generic smooting function has been added.
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
Below are the Flow vs Density plots for each condition.
Verical lines show the congestion Density for each condition.
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
## Warning: Removed 7 rows containing non-finite values (stat_smooth).
We need to find the congestion point for each Delay type and percentile. ### SEGMENT 1
# model_max <- model %>%
# group_by(is_Delay,quantiles) %>%
# # group_by(Delay_type,quantiles) %>%
# # summarise(max = max(.fitted))
# filter(.fitted == max(.fitted)) %>%
# select(is_Delay, quantiles, Cong_Flow = .fitted, Cong_Density = Density_bin)
# # select(Delay_type, quantiles, Cong_Flow = .fitted, Cong_Density = Density_bin)
TT_heat(Rel,1)
TT_heat(Rel,2)
TT_heat(Rel,3)
TT_heat(Rel,4)
TT_heat(Rel,5)
TT_heat(Rel,6)
TT_heat(Rel,7)
TT_heat(Rel,8)
TT_heat(Rel,9)